using System;
using System.Data;
using System.Collections;

namespace RMAS.DAL
{
    /// <summary>
    /// Summary description for WAREHOUSE_PRODUCT.
    /// </summary>
    public class WAREHOUSE_PRODUCTList : CollectionBase
    {
		private string _ErrMsg;
        public string ErrMsg { get { return _ErrMsg; } }
    	public WAREHOUSE_PRODUCTList()
    	{
	    }

		public void Add(WAREHOUSE_PRODUCT entity)
		{
            this.List.Add(entity);
		}

		public void Add(WAREHOUSE_PRODUCTList list)
		{	
			foreach(WAREHOUSE_PRODUCT entity in list)
			{
				this.Add(entity);
			}
		}
	
		public new virtual Enumerator GetEnumerator()
		{
		    return new Enumerator(this);
		}
		public virtual WAREHOUSE_PRODUCT this[int index]
		{
		    get
			{
				return (WAREHOUSE_PRODUCT)this.List[index];
			}
			set
			{
				this.List[index] = value;
			}
		}

		#region Find Object And List Object
		//---PrimaryKey
	public virtual WAREHOUSE_PRODUCT Find(string WHID)
	{
	    foreach (WAREHOUSE_PRODUCT obj in this.List)
	    {
		if(obj.WHID.ToString().ToUpper().Trim() == WHID.ToString().ToUpper().Trim())
		{
		    obj.IsExisting = true;
		    return obj;
		}
	    }
	    return null;
	}

	public virtual WAREHOUSE_PRODUCT FindByPrID(string PrID)
	{
	    foreach (WAREHOUSE_PRODUCT obj in this.List)
	    {
		if(obj.PrID.ToString().ToUpper().Trim() == PrID.ToString().ToUpper().Trim())
		{
		    obj.IsExisting = true;
		    return obj;
		}
	    }
	    return null;
	}

public virtual WAREHOUSE_PRODUCTList FindListByWHID(string WHID)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
		    if(obj.WHID.ToString().ToUpper().Trim() == WHID.ToString().ToUpper().Trim())
		    {
				List.Add(obj);
		    }
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
    	{
		_ErrMsg = ex.Message;
        		return null;
    	}
}

public virtual WAREHOUSE_PRODUCTList FindListByPrID(string PrID)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
		    if(obj.PrID.ToString().ToUpper().Trim() == PrID.ToString().ToUpper().Trim())
		    {
				List.Add(obj);
		    }
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
    	{
		_ErrMsg = ex.Message;
        		return null;
    	}
}
		//---NonPrimaryKey
        public virtual WAREHOUSE_PRODUCT FindByPrName(string PrName)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.PrName.ToString().ToUpper().Trim() == PrName.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByFirstBalance(Int32 FirstBalance)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.FirstBalance.ToString().ToUpper().Trim() == FirstBalance.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByLastBalance(Int32 LastBalance)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.LastBalance.ToString().ToUpper().Trim() == LastBalance.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByAddUp(Int32 AddUp)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.addUp.ToString().ToUpper().Trim() == AddUp.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByAddDown(Int32 AddDown)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.addDown.ToString().ToUpper().Trim() == AddDown.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByMonth(Int16 Month)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.Month.ToString().ToUpper().Trim() == Month.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByYear(Int32 Year)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.Year.ToString().ToUpper().Trim() == Year.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByLog(string Log)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.Log.ToString().ToUpper().Trim() == Log.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByIsLock(bool IsLock)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.IsLock.ToString().ToUpper().Trim() == IsLock.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

        public virtual WAREHOUSE_PRODUCT FindByIDPOS(string IDPOS)
        {
	        foreach (WAREHOUSE_PRODUCT obj in this.List)
	        {
		        if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
		        {
		            obj.IsExisting = true;
		            return obj;
		        }
	        }
	        return null;
        }

public virtual WAREHOUSE_PRODUCTList FindListByPrName(string PrName)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.PrName.ToString().ToUpper().Trim() == PrName.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByFirstBalance(Int32 FirstBalance)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.FirstBalance.ToString().ToUpper().Trim() == FirstBalance.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByLastBalance(Int32 LastBalance)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.LastBalance.ToString().ToUpper().Trim() == LastBalance.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByAddUp(Int32 AddUp)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.addUp.ToString().ToUpper().Trim() == AddUp.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByAddDown(Int32 AddDown)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.addDown.ToString().ToUpper().Trim() == AddDown.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByMonth(Int16 Month)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.Month.ToString().ToUpper().Trim() == Month.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByYear(Int32 Year)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.Year.ToString().ToUpper().Trim() == Year.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByLog(string Log)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.Log.ToString().ToUpper().Trim() == Log.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByIsLock(bool IsLock)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.IsLock.ToString().ToUpper().Trim() == IsLock.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}


public virtual WAREHOUSE_PRODUCTList FindListByIDPOS(string IDPOS)
{
	try
	{
		WAREHOUSE_PRODUCTList List = new WAREHOUSE_PRODUCTList();
		foreach (WAREHOUSE_PRODUCT obj in this.List)
		{
			if(obj.IDPOS.ToString().ToUpper().Trim() == IDPOS.ToString().ToUpper().Trim())
			{
				List.Add(obj);
			}
		}
		if (List.Count > 0) return List;
        		else return null;
	}
	catch(Exception ex)
	{
		 _ErrMsg = ex.Message;
       	 	return null;
    	}
}
		#endregion
     
		#region Inner Classes
		/// <summary>
		/// Type-specific enumeration class, used by LogCollection.GetEnumerator.
		/// </summary>
		public class Enumerator : IEnumerator
		{
			private IEnumerator wrapped;

			public Enumerator(WAREHOUSE_PRODUCTList collection)
			{
				this.wrapped = ((CollectionBase)collection).GetEnumerator();
			}

			public WAREHOUSE_PRODUCT Current
			{
				get
				{
					return (WAREHOUSE_PRODUCT)(this.wrapped.Current);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					return (WAREHOUSE_PRODUCT)(this.wrapped.Current);
				}
			}

			public bool MoveNext()
			{
				return this.wrapped.MoveNext();
			}

			public void Reset()
			{
				this.wrapped.Reset();
			}
      }
      #endregion  
   }
}